package com.wcs.exam.controller.admin;

import com.wcs.exam.common.base.Result;
import com.wcs.exam.common.base.page.Page;
import com.wcs.exam.controller.admin.biz.AdminUserAttendanceBiz;
import com.wcs.exam.controller.admin.req.AdminUserAttendanceEditReq;
import com.wcs.exam.controller.admin.req.AdminUserAttendancePageReq;
import com.wcs.exam.controller.admin.req.AdminUserAttendanceSaveReq;
import com.wcs.exam.controller.admin.req.AdminUserAttendanceSortReq;
import com.wcs.exam.controller.admin.resp.AdminUserAttendancePageResp;
import com.wcs.exam.controller.admin.resp.AdminUserAttendanceViewResp;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import jakarta.validation.Valid;
import jakarta.validation.constraints.NotNull;
import java.util.List;

/**
 * Admin-用户考勤
 *
 * @author wcs
 * @since 2025-03-13
 */
@Tag(name = "Admin-用户考勤")
@RestController
@RequiredArgsConstructor
@RequestMapping("/v1/admin/user/attendance")
public class AdminUserAttendanceController {

    @NotNull
    private final AdminUserAttendanceBiz biz;

    @Operation(summary = "用户考勤-分页")
    @GetMapping(value = "/page")
    public Result<Page<AdminUserAttendancePageResp>> page(@ModelAttribute AdminUserAttendancePageReq req) {
        return biz.page(req);
    }

    @Operation(summary = "用户考勤-添加")
    @PostMapping(value = "/save")
    public Result<String> save(@RequestBody @Valid AdminUserAttendanceSaveReq req) {
        return biz.save(req);
    }

    @Operation(summary = "用户考勤-查看")
    @Parameter(name = "id", description = "主键ID", required = true)
    @GetMapping(value = "/view")
    public Result<AdminUserAttendanceViewResp> view(@RequestParam Long id) {
        return biz.view(id);
    }

    @Operation(summary = "用户考勤-编辑")
    @PutMapping(value = "/edit")
    public Result<String> edit(@RequestBody @Valid AdminUserAttendanceEditReq req) {
        return biz.edit(req);
    }

    @Operation(summary = "用户考勤-排序")
    @PutMapping(value = "/sort")
    public Result<String> sort(@RequestBody @Valid List<AdminUserAttendanceSortReq> reqs) {
        return biz.sort(reqs);
    }

    @Operation(summary = "用户考勤-删除")
    @Parameter(name = "id", description = "主键ID", required = true)
    @DeleteMapping(value = "/delete")
    public Result<String> delete(@RequestParam Long id) {
        return biz.delete(id);
    }
}
